package cn.jly.spring.boot.cloud.beans;

import lombok.Data;
import org.hibernate.validator.constraints.Range;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
import org.springframework.validation.annotation.Validated;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotEmpty;
import java.util.List;
import java.util.Map;

/**
 * @author lanyangji
 * @description person bean，从配置文件中获取
 * @date 2020/11/6 下午 3:10
 */
@Validated
@Data
@Component
@ConfigurationProperties(prefix = "person")
@PropertySource("classpath:person.properties")
public class Person {
    private Long id;
    @NotEmpty(message = "姓名不能为空")
    private String name;
    @Email(message = "必须为一个合法的邮箱格式")
    private String email;
    @Range(min = 1, max = 150, message = "年龄必须在1-150之间")
    private Integer age;
    private List<String> hobbies;
    /**
     * 个性
     */
    private Map<String, String> characteristics;
    @Autowired
    private BootArgs bootArgs;
}
